<?php
/**
 * Created by PhpStorm.
 * User: zhendanxu
 * Date: 2019/4/25
 * Time: 10:17 AM
 */

namespace AppBundle\Controller;


use Symfony\Component\Routing\Generator\UrlGeneratorInterface;

class MainController extends BaseController
{
    public function showAction($slug)
    {
        echo $url = $this->generateUrl(
            'blog_show',
            array('slug' => 'my-blog-post')
        );

        echo "<br>";
        // /blog/2?category=Symfony
        echo $this->get('router')->generate('blog_list', array(
            'page' => 2,
            'category' => 'Symfony'
        ));

        echo "<br>";
        // http://www.example.com/blog/my-blog-post
        echo $this->generateUrl('blog_show', array('slug' => 'my-blog-post'), UrlGeneratorInterface::ABSOLUTE_URL);

        return $this->render('main/main.html.twig', array());
    }
}